<?php
session_start();
include '../business/user_manager.php';
include_once '../entity/user_entity.php';

$email = $_POST['login_email'];
$passwd = $_POST['login_passwd'];

$userMng = new UserMng();
$userEntity = $userMng->login($email, $passwd);

if (isset($userEntity)) {
    $_SESSION['userID'] = $userEntity->id;
    $_SESSION['name'] = split('@', $email, 0);
    $_SESSION['userType'] = $userEntity->type;
    echo "<script>window.location.href='dashboard.php'</script>";
} else {
    echo "Login failed";
}

?>
